import sys
from antlr4 import *

from HatLexer import HatLexer
from HatParser import HatParser
from miniSysYLexer import miniSysYLexer
from miniSysYParser import miniSysYParser
from HatVisitor import HatVisitor


def main(argv):
    input_stream = FileStream(argv[1])
    lexer = HatLexer(input_stream)
    stream = CommonTokenStream(lexer)
    parser = HatParser(stream)
    tree = parser.compUnit()
    print(tree.toStringTree(recog=parser))
    print("_________________________________________________________")
    visitor = HatVisitor()
    visitor.visitCompUnit(tree)
    print("_________________________________________________________")

def preProcess():
    pass

if __name__ == '__main__':
    main(sys.argv)
    exit(0)
